<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/28/0028
 * Time: 17:04
 */

namespace app\sports_admin\model;


use think\Model;

class Login extends Model
{
    protected $table = 'admin';

    protected $pk = 'id';

    protected $hidden = ['last_time','add_time'];
    //查询管理员权限
    public function adminRule()
    {
        return $this->hasOne('admin_rule', 'admin_id', 'id');
    }

    /**
     * 判断账号是否存在
     * @param $account 管理员账号
     */
    public static function findAdmin($account)
    {
        return self::where('login', $account)->find();
    }
    /**
     * 获取管理员权限
     * @param $adminId 管理员id
     */
    public static function getAdminRule($adminId)
    {
        return self::with('adminRule,adminRule.getRule')->find($adminId)->hidden(['pwd']);
    }
}